package com.itheima.heimaai.repository;

import org.springframework.stereotype.Component;

import java.util.*;

@Component
public class InMemoryChatHistoryRepository implements ChatHistoryRepository {

    private final Map<String, Set<String>> history = new HashMap<>();

    @Override
    public void save(String type, String chatId) {
        if (!history.containsKey(type)){
            history.put(type,new HashSet<>());
        }
        history.get(type).add(chatId);
    }

    @Override
    public Set<String> list(String type) {
        return history.get(type)==null?Collections.emptySet():history.get(type);
    }
}
